package singleton;

public class HighPrecisionNavigationSystem {
    private static HighPrecisionNavigationSystem instance;
    private String currentLocation;
    private double heading;
    private double speed;

    private HighPrecisionNavigationSystem() {
        // 私有构造函数
        currentLocation = "初始位置";
        heading = 0.0;
        speed = 0.0;
        System.out.println("高精度定位与惯性导航系统初始化完成");
    }

    public static synchronized HighPrecisionNavigationSystem getInstance() {
        if (instance == null) {
            instance = new HighPrecisionNavigationSystem();
        }
        return instance;
    }

    public void updateLocation(String location) {
        this.currentLocation = location;
        System.out.println("导航系统位置更新为: " + location);
    }

    public void updateHeading(double heading) {
        this.heading = heading;
        System.out.println("导航系统航向更新为: " + heading + "度");
    }

    public void updateSpeed(double speed) {
        this.speed = speed;
        System.out.println("导航系统速度更新为: " + speed + "公里/小时");
    }

    public String getNavigationInfo() {
        return "位置: " + currentLocation + ", 航向: " + heading + "度, 速度: " + speed + "公里/小时";
    }
}    